<!DOCTYPE html>
<html>
<head>
<title>编辑角色</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>编辑角色</h5>
            </div>
           <form id="inputForm" action="update" method="post">
           		<input type="hidden" name="id" value="#(role.id)">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">名称：</label>
	                        <div class="col-sm-3">
	                            <input class="form-control" type="text" name="name" value="#(role.name)">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">描述：</label>
	                        <div class="col-sm-3">
	                            <input class="form-control" type="text" name="description" value="#(role.description)">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">商品管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/product" #if(role.permissions.contains("/admin/product")) checked="checked" #end/>商品管理
									</label>
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/product_category" #if(role.permissions.contains("/admin/product_category")) checked="checked" #end/>商品分类
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/brand" #if(role.permissions.contains("/admin/brand")) checked="checked" #end/>品牌管理
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">秒杀管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/seckill" #if(role.permissions.contains("/admin/seckill")) checked="checked" #end/>秒杀管理
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">拼团管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/group" #if(role.permissions.contains("/admin/group")) checked="checked" #end/>拼团管理
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">优惠券管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/coupon" #if(role.permissions.contains("/admin/coupon")) checked="checked" #end/>优惠券管理
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">文章管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/article_category" #if(role.permissions.contains("/admin/article_category")) checked="checked" #end/>文章分类
									</label>
									<label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/article" #if(role.permissions.contains("/admin/article")) checked="checked" #end/>文章管理
                                    </label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">会员管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/member" #if(role.permissions.contains("/admin/member")) checked="checked" #end/>会员管理
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/member_rank" #if(role.permissions.contains("/admin/member_rank")) checked="checked" #end/>会员等级
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
                            <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">订单管理：</a></label>
                            <div class="col-sm-3">
                                 <div class="checkbox">
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/order" #if(role.permissions.contains("/admin/order")) checked="checked" #end/>订单管理
                                    </label>
                                </div>
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">分销管理：</a></label>
                            <div class="col-sm-3">
                                 <div class="checkbox">
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/distribute" #if(role.permissions.contains("/admin/distribute")) checked="checked" #end/>分销设置
                                    </label>
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/distribute_rank" #if(role.permissions.contains("/admin/distribute_rank")) checked="checked" #end/>分销级别
                                    </label>
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/commission" #if(role.permissions.contains("/admin/commission")) checked="checked" #end/>佣金管理
                                    </label>
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/withdraw" #if(role.permissions.contains("/admin/withdraw")) checked="checked" #end/>提现管理
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">财务管理：</a></label>
                            <div class="col-sm-3">
                                 <div class="checkbox">
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/payment" #if(role.permissions.contains("/admin/payment")) checked="checked" #end/>财务管理
                                    </label>
                                </div>
                            </div>
                        </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">广告管理：</a></label>
	                        <div class="col-sm-3">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/ad" #if(role.permissions.contains("/admin/ad")) checked="checked" #end/>广告
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/ad_position" #if(role.permissions.contains("/admin/ad_position")) checked="checked" #end/>广告位
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/friend_link" #if(role.permissions.contains("/admin/friend_link")) checked="checked" #end/>友情链接
									</label>
								</div>
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label"><a href="javascript:;" class="selectAll" title="全选此组权限">系统管理：</a></label>
	                        <div class="col-sm-8">
	                        	 <div class="checkbox">
	                           		<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/role" #if(role.permissions.contains("/admin/role")) checked="checked" #end/>角色
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/admin" #if(role.permissions.contains("/admin/admin")) checked="checked" #end/>管理员
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/area" #if(role.permissions.contains("/admin/area")) checked="checked" #end/>地区
									</label>
									<label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/config" #if(role.permissions.contains("/admin/config")) checked="checked" #end/>系统设置
                                    </label>
                                    <label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/message_config" #if(role.permissions.contains("/admin/message_config")) checked="checked" #end/>消息配置
                                    </label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/template" #if(role.permissions.contains("/admin/template")) checked="checked" #end/>模板
									</label>
									<label class="m-r">
										<input class="checkbox" type="checkbox" name="permissions" value="/admin/cache" #if(role.permissions.contains("/admin/cache")) checked="checked" #end/>清除缓存
									</label>
									<label class="m-r">
                                        <input class="checkbox" type="checkbox" name="permissions" value="/admin/database" #if(role.permissions.contains("/admin/database")) checked="checked" #end/>数据库
                                    </label>
								</div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	                <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	var $selectAll = $("#inputForm .selectAll");
	
	
	
	$selectAll.click(function() {
		var $this = $(this);
		var $thisCheckbox = $this.closest("div").find("input:checkbox");
		if ($thisCheckbox.filter(":checked").size() > 0) {
			$thisCheckbox.prop("checked", false);
		} else {
			$thisCheckbox.prop("checked", true);
		}
		return false;
	});
	
	// 表单验证
	$inputForm.validate({
		rules: {
			name: "required",
			permissions: "required"
		}
	});

});
</script>